Developer(s) | Tibbo Technology, Inc. |
---|---|
Stable release | 2.5 / June 2011 |
Operating system | Windows development; TiOS (Tibbo Operating System) for running on embedded devices. |
Type | BASIC |
License | Copyright © 2000-2011 Tibbo Technology, Inc., Proprietary |
Tibbo BASIC is a dialect of the BASIC programming language, designed for programmable logic controllers, Ethernet modules and other programmable hardware devices, both external and internal (embeddable). It is developed and distributed by Tibbo Technology Inc., a leading manufacturer of programmable Ethernet converters and controllers in Taipei, Taiwan.[1][2]
Contents |
The programming language features of Tibbo BASIC are motivated by its use in building software applications for small external devices that need to perform fast, have access only to a small memory space and are robust under failure. These requirements determine both the power of the language and its limitations for adopting it for widely different purposes.[3]
For optimized performance on embedded devices, the language was designed as an explicitly, strongly and statically typed, asynchronous, event-driven programming language with object extensions and implicit error handling. Continuation-style event-handling is supported by special doevents statements to handle high-priority events.[4] To speed up run-time performance, the source code is transformed by a specially developed BASIC compiler[note 1] into intermediate-level code ("pseudo-code") and later interpreted and executed by a virtual machine for added resilience under failure.
Allowed variable types include byte, word, dword, char, short, long, real, boolean and user-defined structures and enumeration types[4]. Both integer arithmetic and floating point arithmetic are supported.[5]
Input-output functions, specific to a particular hardware device, are separated out from the rest of the language (called the core), making the remaining language in some sense more pure.[4]
The hardware devices are conceptualized in terms of platforms.[5] Each platform is characterized by a particular set of predefined objects, properties, methods and events that describe its capabilities, e.g. storing data in memory or opening up a TCP connection and sending a message.[note 2] Objects are independent of each other and not defined in terms of classes or class hierarchies but their significance lies in treating complex low-level hardware constructs and operations as simple high-level primitives and thus greatly simplifying programming and reprogramming the device.[3] As an example, the following code establishes a TCP connection with a target device (here assumed to have a default IP address) and sends the specified message:
sub on_button_pressed sock.connect sock.setdata("This is a string waiting to be sent.") sock.send end sub
Tibbo BASIC core language can contain user-defined structures but no objects or methods.[4]
Debugging of programs is done in the development environment, without a need for external in-circuit emulators, as is common with programs written in hardware description languages for embedded devices.
Tibbo BASIC is part of a rapid programming framework, called TAIKO, that includes also an Integrated Development Environment and a specialized Operating System.[3]
The Integrated Development Environment, called TIDE, contains a source code editor, a compiler and a debugger.[6]
The graphical source code editor is used to facilitate the writing of the programs;[7] Tibbo BASIC source code is saved in files with .tbs file suffix.
The compiler is used for translating the source-code from the high-lever user-friendly format into a lower-level pseudo-code (.tpc suffix for Tibbo pseudo-code).
The debugger is used for checking that the program performs without errors. To verify this, the target hardware device is connected to the personal computer on which the program was developed, and the program is executed with different variable assignments and by triggering different combinations of possible events. While the program is running on the embedded device, its control flow and parameter settings can be observed in TIDE.
The programs on the embedded device run in a special operating system, called TiOS (Tibbo Operating System).[3] TiOS runs two processes, the Master Process and the VM (virtual machine).[5]
The Master Process controls communications with VM, TIDE and the events generated on the device. The VM interprets the compiled form of the program from the pseudo-code further into native binary code that the hardware processor can understand, and executes the program.
Because the VM is under the control of the Master Process, the Master Process can restart the VM (and so also the Tibbo BASIC program) if there are errors in the program that make the VM crash, and send information to TIDE about the execution state of the program during the crash for debugging and correcting.
The following example shows Tibbo BASIC code that on an embedded device that is equipped with a button and green and red LED lights, after a user presses the button, outputs "Hello World!" in Morse code by the blinking of the lights. The line symbol of the Morse code is represented by a long pulse of the green light ('GGG') and the dot symbol by a short pulse of the red light ('R'). Line ('-') means that both lights are off.
'=============================================================================== ' HELLO WORLD IN MORSE CODE '=============================================================================== dim hello_world as string dim length, play_position as integer const PAT_PLAY_CHUNK_LENGTH = 15 declare sub play_next '-------------------------------------------------------------------- ----------- sub on_sys_init hello_world = "R-R-R-R---R---R-GGG-R-R---R-GGG-R-R---GGG-GGG-GGG" + "-------" + "R-GGG-GGG---GGG-GGG-GGG---R-GGG-R---R-GGG-R-R---GGG-R-R" + "-------" + "R-R-GGG-GGG-R-R-" length = len(hello_world) play_position = 0 end sub '------------------------------------------------------------------------------- sub on_button_pressed play_position = 1 play_next end sub '------------------------------------------------------------------------------- sub on_pat play_next end sub '------------------------------------------------------------------------------- sub play_next if length < play_position then exit sub dim chunk_len as integer chunk_len = length - play_position + 1 if chunk_len > PAT_PLAY_CHUNK_LENGTH then chunk_len = PAT_PLAY_CHUNK_LENGTH dim chunk as string chunk = mid(hello_world, play_position, chunk_len) pat.play(chunk, YES) play_position = play_position + chunk_len end sub